<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品交接单</title>
    <link rel="stylesheet" href="/js/elementui/index.css">
    <script src="/js/vue/vue.js"></script>
    <script src="/js/axios/axios.min.js"></script>
    <script src="/js/qs/qs.min.js"></script>
    <script src="/js/elementui/index.js"></script>
    <style>
        .pat{
            width: 300px;
        }
    </style>
</head>
<body>
<div id="app">
<span>交接单查询:</span><el-input v-model="input1" placeholder="请输入订单编号" class="pat" clearable></el-input>
<el-button icon="el-icon-search" type="primary" @click="selectOne">查询</el-button><br><br><br>

    <el-button type="danger" @click="deleteAll">自批量删除</el-button><br><br><br>
        <el-table
                ref="multipleTable"
                :data="tableData"
                tooltip-effect="dark"
                style="width: 100%"
                @selection-change="handleSelectionChange">
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    label="交接单号"
                   >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.id }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="订单编号"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.orderId }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="产品名称"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.pName }}</span>
                </template>
            </el-table-column>
            <!--<el-table-column
                    label="产品型号"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.pNumber }}</span>
                </template>
            </el-table-column>-->
            <el-table-column
                    label="生产部门"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.productionName }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="收货仓库"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.wareName }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="入库数量"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.num }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="交接日期"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.handoverDate }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="交接人"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.head }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="备注"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.remake }}</span>
                </template>
            </el-table-column>
            <el-table-column
                    label="状态"
            >
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.state1 }}</span>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope" >
                    <el-button
                               size="mini"
                               @click="handleEdit(scope.$index, scope.row)">打印交接单</el-button>

                </template>
            </el-table-column>
        </el-table>


    <!--分页-->
    <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="current"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
    </el-pagination>

    <!--显示-->

    <el-dialog title="设置生产记录" :visible.sync="dialogFormVisible" @close="closeMyDialog">
        <el-form :model="productHandoverAll">
            <el-form-item label="交接单号" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.id" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="订单编号" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.orderId" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="产品名称" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.pName" autocomplete="off"></el-input>
            </el-form-item>
           <!-- <el-form-item label="产品型号" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.pNumber" autocomplete="off"></el-input>
            </el-form-item>-->
            <el-form-item label="生产部门" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.productionName" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="收货仓库" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.wareName" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="入库数量" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.num" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="交接日期" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.handoverDate" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="交接人" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.head" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="备注" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.remake" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="状态" :label-width="formLabelWidth">
                <el-input v-model="productHandoverAll.state1" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">关闭</el-button>
        </div>
    </el-dialog>

</div>
</body>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                input1:"",
                current:1,
                total:0,
                pageSize:5,
                tableData:null,
                formLabelWidth:null,

                dialogFormVisible:false,
                multipleSelection: [],
                productHandoverAll:{
                    id:"",
                    orderId:"",
                    pName:"",
                    pNumber:"",
                    productionName:"",
                    wareName:"",
                    num:"",
                    handoverDate:"",
                    head:"",
                    remake:"",
                    state1:""
                }
            }
        },
        methods:{
            selectOne(){
                this.pageSize=5
                this.total=0
                this.current=1
                this.loadPage(1,5)
            },
            handleEdit(index, row) {
                console.log(index, row);
                this.productHandoverAll=row
                this.dialogFormVisible =true
            },
            //关闭对话框
            closeMyDialog(){
                //清空数据
                this.productHandoverAll = {      //产品对话框的数据
                    id:"",
                    orderId:"",
                    pName:"",
                    pNumber:"",
                    productionName:"",
                    wareName:"",
                    num:"",
                    handoverDate:"",
                    head:"",
                    remake:"",
                    state1:""
                }
            },
            handleSizeChange(pageSize) {
                //console.log(`每页 ${val} 条`);
                this.loadPage(this.current,pageSize)
            },
            handleCurrentChange(current) {
                //console.log(`当前页: ${val}`);
                this.loadPage(current,this.pageSize)
            },
            deleteAll(){
                var arr=[];
                for (var i = 0; i <this.multipleSelection.length ; i++) {
                    arr[i]=this.multipleSelection[i].id
                }
                axios.delete("/productHandover?arr="+arr).then(value => {
                    if(value.data.code==1){
                        this.loadPage(this.current,this.pageSize)
                    }
                })
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;

            },
            loadPage(current,pageSize){
                this.current=current
                this.pageSize=pageSize
                if(this.input1==""){
                    axios.get("/productHandover?current="+current+"&pageSize="+pageSize).then(value => {
                        if(value.data.code==1){
                            this.tableData=value.data.data.records
                            this.total = value.data.data.total
                            this.pageSize = value.data.data.size
                            this.current = value.data.data.current
                        }
                    })
                }else {
                    axios.get("/productHandover1?current="+current+"&pageSize="+pageSize+"&orderId="+this.input1).then(value => {
                        if(value.data.code==1){
                            this.tableData=value.data.data.records
                            this.total = value.data.data.total
                            this.pageSize = value.data.data.size
                            this.current = value.data.data.current
                        }
                    })
                }

            }
        },
        mounted(){
            this.loadPage(1,5)
        }
    })
</script>
</html>